{% extends 'dashboard/base.html' %}
{% block body %}

<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script type="text/javascript">

    $("#checkAll").change(function () {
        $("input:checkbox").prop('checked', $(this).prop("checked"));
    });
    $(document).ready(function() {
        $("button").click(function(){
            var scan_id = ['a7af5b68-b661-45ad-90fd-ffa27526cdce'];
            $.each($("input[name='del_vuln_id']:checked"), function(){
                scan_id.push($(this).val());
            });

            var json_scanid = scan_id.join(", ");
            $.ajax({
                type:'POST',
                <!--contentType: 'application/json; charset=utf-8',-->
                url:'/tools/nikto_vuln_del/',
                data:{
                   del_vuln: json_scanid,
                   scan_id: $('input[name=scan_id]').val(),
                   csrfmiddlewaretoken:$('input[name=csrfmiddlewaretoken]').val()
                },
                sucess:function(){
                }
            });
            setTimeout(function(){location.reload();},1000);
        });

    });

$(document).on('click', '.confirm-delete', function(){
    return confirm('Are you sure you want to delete this?');
})

</script>

        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="card-body">
                        <div class="float-right">
                            <button type="button" class="btn btn-danger btn-mini" onclick="">Delete Selected</button>
                        </div>
                        <br>
                        <div class="d-md-flex align-items-center">
                            <h5 class="card-title">Vulnerability List</h5>
                        </div>
                        <br>
                        <div class="row">
                            <div class="table-responsive">
                                <!--<table id="vuln_details" class="table table-striped table-bordered" width="100%">-->
                                <table id="nikto_scans_list" class="table table-bordered data-table">
                                    <thead>
                                    <tr>
                                        <th><label class="customcheckbox m-b-20">
                                            <input type="checkbox" id="mainCheckbox">
                                            <span class="checkmark"></span>
                                        </label></th>
                                        <th>Vulnerability</th>
                                    <th>URL</th>
                                    <th>False Positive</th>
                                    <th></th>
                                    <th></th>
                                    </tr>
                                    </thead>
                                    <tbody>{% for data in vuln_data %}
                                    <tr data-target="#">
                                        <td>
                                            <form>
                                                <label class="customcheckbox">
                                                    <input type="checkbox" class="listCheckbox"
                                                           value="{{data.vuln_id}}"
                                                           name="del_vuln_id"
                                                           onClick="reload">
                                                    <span class="checkmark"></span>
                                                </label>
                                            </form>
                                        </td>
                                        <td><a href="#">{{data.discription}}</a>
                                    </td>
                                    <td>{{data.uri}}</td>
                                    <!--<td><a href="{{jira_url}}browse/{{data.jira_ticket}}" target="_blank">{{data.jira_ticket}}</a>-->
                                    </td>
                                    <td>
                                        <form method="POST" action="/tools/nikto_result_vul/">{% csrf_token %}
                                            <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                            <input type="hidden" name="false" value="Yes">
                                            <input type="hidden" name="status" value="{{data.vuln_status}}">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-info btn-mini">Yes</button>
                                        </form>
                                    </td>
                                    <td>
                                        <div class="confirm-delete">
                                            <form action="/tools/nikto_vuln_del/" method="POST" class="form-horizontal">
                                                {% csrf_token %}
                                                <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                                <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                                <button class="btn btn-danger"><i class="fas fa-times"></i></button>
                                            </form>
                                        </div>
                                    </td>
                                    <td>
                                        <form method="POST" action="/tools/nikto_result_vul/">{% csrf_token %}
                                            <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                            <input type="hidden" name="false" value="No">
                                            <input type="hidden" name="status" value="Closed">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-danger btn-mini">Close</button>
                                        </form>
                                    </td>
                                    </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <br>
                        <div class="d-md-flex align-items-center">
                            <h5 class="card-title">False Positive Vulnerability List</h5>
                        </div>
                        <br>
                        <div class="row">
                            <div class="table-responsive">
                                <table id="zap_scans_list_false" class="table table-bordered data-table">
                                    <thead>
                                    <tr>
                                        <th><label class="customcheckbox m-b-20">
                                            <input type="checkbox" id="mainCheckbox1">
                                            <span class="checkmark"></span>
                                        </label></th>
                                         <th>Vulnerability</th>
                                    <th>URL</th>
                                    <th>False Positive</th>
                                    <th></th>
                                    </tr>
                                    </thead>
                                    <tbody>{% for data in false_data %}
                                    <tr data-target="#">
                                        <td>
                                            <form>
                                                <label class="customcheckbox">
                                                    <input type="checkbox" class="listCheckbox1"
                                                           value="{{data.vuln_id}}"
                                                           name="del_vuln_id"
                                                           onClick="reload">
                                                    <span class="checkmark"></span>
                                                </label>
                                            </form>
                                        </td>
                                         <td><a href="#">{{data.discription}}</a>
                                    </td>
                                    <td>{{data.uri}}</td>
                                    <td>
                                        <form method="POST" action="/tools/nikto_result_vul/">{% csrf_token %}
                                            <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                            <input type="hidden" name="false" value="No">
                                            <input type="hidden" name="status" value="{{data.vuln_status}}">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-info btn-mini">No</button>
                                        </form>
                                    </td>
                                   <td>
                                        <div class="confirm-delete">
                                            <form action="/tools/nikto_vuln_del/" method="POST" class="form-horizontal">
                                                {% csrf_token %}
                                                <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                                <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                                <button class="btn btn-danger"><i class="fas fa-times"></i></button>
                                            </form>
                                        </div>
                                    </td>
                                    </tr>
                                    {% endfor %}
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="card">
                    <div class="card-body">
                        <br>
                        <div class="d-md-flex align-items-center">
                            <h5 class="card-title">Closed Vulnerability list</h5>
                        </div>
                        <br>
                        <div class="table-responsive">
                            <table id="zap_scans_list_close" class="table table-bordered data-table">
                                <thead>
                                <tr>
                                    <th><label class="customcheckbox m-b-20">
                                        <input type="checkbox" id="mainCheckbox2">
                                        <span class="checkmark"></span>
                                    </label></th>
                                   <th>Vulnerability</th>
                                    <th>URL</th>
                                    <th></th>
                                    <th></th>
                                </tr>
                                </thead>
                                <tbody>{% for data in vuln_data_close %}
                                <tr data-target="#">
                                    <td>
                                        <form>
                                            <label class="customcheckbox">
                                                <input type="checkbox" class="listCheckbox2"
                                                       value="{{data.vuln_id}}"
                                                       name="del_vuln_id"
                                                       onClick="reload">
                                                <span class="checkmark"></span>
                                            </label>
                                        </form>
                                    </td>
                                    <td><a href="/zapscanner/zap_vuln_check/?vuln_id={{data.vuln_id}}">{{data.discription}}</a>
                                    </td>
                                    <td>{{data.uri}}</td>
                                    <td>
                                        <div class="confirm-delete">
                                            <form action="/tools/nikto_vuln_del/" method="POST" class="form-horizontal">
                                                {% csrf_token %}
                                                <input type="hidden" name="del_vuln" value="{{data.vuln_id}}">
                                                <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                                <button class="btn btn-danger"><i class="fas fa-times"></i></button>
                                            </form>
                                        </div>
                                    </td>
                                    <td>
                                        <form method="POST" action="/tools/nikto_result_vul/">{% csrf_token %}
                                            <input type="hidden" name="vuln_id" value="{{data.vuln_id}}">
                                            <input type="hidden" name="false" value="No">
                                            <input type="hidden" name="status" value="Open">
                                            <input type="hidden" name="scan_id" value="{{data.scan_id}}">
                                            <button class="btn btn-info btn-mini">Open</button>
                                        </form>
                                    </td>
                                </tr>
                                {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>


{% endblock %}